package com.yoomiito.app.widget.dialog;

import android.content.Context;
import androidx.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.yoomiito.app.R;
import com.yoomiito.app.listener.OnViewClickListener;
import com.yoomiito.app.model.home.FreeBuyActInfo;

/**
 * 0元购
 */
public class FreeBuyDialog extends BaseDialog implements View.OnClickListener {
    private OnViewClickListener mOnViewClickListener;
    private FreeBuyActInfo mFreeBuyActInfo;

    public FreeBuyDialog(@NonNull Context context) {
        this(context,0);
    }

    public FreeBuyDialog(@NonNull Context context, int themeResId) {
        super(context, R.style.dialog_2);
    }

    @Override
    public View setView() {
        View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_0_yuangou,null,false);
        view.findViewById(R.id.cancel).setOnClickListener(this);
        view.findViewById(R.id.bg_now_buy).setOnClickListener(this);
        setCanceledOnTouchOutside(true);
        setmHeightPercent(1);
        setWidthPercent(1);
        TextView content = view.findViewById(R.id.content);
        TextView date = view.findViewById(R.id.date);
        if (mFreeBuyActInfo!=null){
            content.setText(mFreeBuyActInfo.getDes());
            date.setText(mFreeBuyActInfo.getTime());
        }
        return view;
    }



    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.cancel:
                dismiss();
                break;
            case R.id.bg_now_buy:
                if (mOnViewClickListener!=null){
                    mOnViewClickListener.onClick(v);
                }
                break;
        }
    }

    public void setOnViewClickListener(OnViewClickListener onViewClickListener) {
        mOnViewClickListener = onViewClickListener;
    }

    public void setFreeBuyActInfo(FreeBuyActInfo freeBuyActInfo) {
        mFreeBuyActInfo = freeBuyActInfo;
    }
}
